<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">    
    <title>IFE ECMAScript</title>
</head>
<body>        
    <input id="name" type="text">    
    <button id="submit-btn">Submit</button>
</body>
</html>
<script>
    function outPrint (){
        console.log(document.getElementById('name').value);
    }
    document.getElementById('submit-btn').addEventListener('click',outPrint);
    document.onkeydown = function(event){
        console.log(event);
        if(event.keyCode == 13){
            console.log(document.getElementById('name').value);
        }else if(event.keyCode == 27){
            document.getElementById('name').value = '';
        }
    }
</script>